import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
var defaultCity = ''
try {
    if(localStorage.city){
        defaultCity = localStorage.city
    }
} catch (error) {
    
}
export default new Vuex.Store({
   state:{
       city:defaultCity
   },
   actions:{
       changeCityName(ctx,city){
          ctx.commit('changeCityName',city)
       }
   },
   mutations:{
       changeCityName(state,city){
           state.city = city;
           localStorage.city = city;
       }
   }
})